from sanic import Sanic
from db_connect import ConnMysql
from db_connect import ConnRedis
from db_connect import ConnMysqlSlave

from user_information import app_user

from product_api import bp_product

from vender import app_user_update

app = Sanic("App Name")

app.static('/static', './static')

app.blueprint(app_user)

app.blueprint(bp_product)

app.blueprint(app_user_update)
@app.listener('after_server_start')
async def notify_server_started(app, loop):
    ConnMysql(loop=loop)
    ConnRedis(loop=loop)
    ConnMysqlSlave(loop=loop)
    print('Server MySql and Redis successfully started!')


if __name__ == "__main__":

    app.run(port=8000, debug=True)